package LeetCode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class LC_506_RelativeRanks {

    public static void main(String[] args) {

    }

    public class Solution {
        public String[] findRelativeRanks(int[] nums) {
            String[] copy = new String[nums.length];
            Map<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < nums.length; i++)
                map.put(nums[i], i);
            Arrays.sort(nums);
            int j = 0;
            for (int i = nums.length - 1; i >= 0; i--) {
                if (i >= nums.length - 3) {
                    String[] metal = {"Gold Medal", "Silver Medal", "Bronze Medal"};
                    copy[map.get(nums[i])] = metal[j++];
                } else {
                    copy[map.get(nums[i])] = String.valueOf(nums.length - i);
                }
            }
            return copy;
        }

    }


}